<?php
/*
YHM (Your Hosting Manager) - Copyright 2010 All Rights Reserved. - YHM Group
Released under the Simplified BSD Licence.

Website: http://yhm.co.uk
Licence: http://yhm.co.uk/about/#licence

file: client/status.php
author: 
*/

//Init Includes, Sessions and Page Info
require_once("../global.php");
session_start();
checklogin_client();
$username = $_SESSION['user_name'];
$page = "status";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>YHM - Client CP - Server Status</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />
</head>
<body>

<?php include("./header.php"); ?>

	<div id="content">

<h2>Server Status</h2>

<?php


//Services to Check
$services=array(
'HTTP (Port 80)' => array('localhost' => 80),
'HTTPS (Port 443)' => array('localhost' => 443),
'FTP (Port 21)' => array('localhost' => 21),
'MySQL (Port 3306)' => array('localhost' => 3306),
'SSH (Port 2222)' => array('localhost' => 2222),
'POP3 (Port 110)' => array('localhost' =>  110),
'SMTP (Port 25)' => array('localhost' =>  25),
'cPanel (Port 2082)' => array('localhost' => 2082)
);

function ServerCheck($server = 'localhost', $port = '80')
{
	//Connection
	$fp=@fsockopen($server, $port, $errno, $errstr, 1);
	
	//Check if connection is present
	if($fp)
	{
		return "Online";
	}
	else
	{
		return "Offline";
	}

	//Close Connection
	fclose($fp);
}

function CheckAll()
{
	//Check All Services
	global $services;
	
	foreach($services as $name => $server)
	{
		foreach($server as $host => $port)
		{
			$status[$name] = ServerCheck($host,$port);
		}
	}
	
	return $status;
}

foreach(CheckAll() as $service => $stat)
{
	echo $service . " - " . $stat . "<br /><br />";
}
?>
<?php include '../footer.php'; ?>
</div>
</body>
</html>